package com.blogsoho.taurus.dao.mapper;

import com.blogsoho.taurus.vo.CategoryCountVO;
import com.blogsoho.taurus.vo.ContentVO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * Created by user on 2017/6/5.
 */
@Mapper
public interface CategoryMapper {

    @Select("select * from taurus_content where object_id is not null and object_id>0;")
    @Results(id = "content", value = {@Result(property = "id", column = "id"),
            @Result(property = "title", column = "title"), @Result(property = "text", column = "text"),
            @Result(property = "summary", column = "summary"), @Result(property = "linkTo", column = "link_to"),
            @Result(property = "markdownEnable", column = "markdown_enable"),
            @Result(property = "thumbnail", column = "thumbnail"), @Result(property = "module", column = "module"),
            @Result(property = "style", column = "style"), @Result(property = "userId", column = "user_id"),
            @Result(property = "author", column = "author"), @Result(property = "userEmail", column = "user_email"),
            @Result(property = "userIp", column = "user_ip"), @Result(property = "userAgent", column = "user_agent"),
            @Result(property = "parentId", column = "parent_id"), @Result(property = "objectId", column = "object_id"),
            @Result(property = "orderNumber", column = "order_number"), @Result(property = "status", column = "status"),
            @Result(property = "voteUp", column = "vote_up"), @Result(property = "voteDown", column = "vote_down"),
            @Result(property = "rate", column = "rate"), @Result(property = "rateCount", column = "rate_count"),
            @Result(property = "price", column = "price"),
            @Result(property = "commentStatus", column = "comment_status"),
            @Result(property = "commentCount", column = "comment_count"),
            @Result(property = "commentTime", column = "comment_time"),
            @Result(property = "viewCount", column = "view_count"), @Result(property = "created", column = "created"),
            @Result(property = "modified", column = "modified"), @Result(property = "slug", column = "slug"),
            @Result(property = "flag", column = "flag"), @Result(property = "lng", column = "lng"),
            @Result(property = "lat", column = "lat"), @Result(property = "metaKeywords", column = "meta_keywords"),
            @Result(property = "metaDescription", column = "meta_description"),
            @Result(property = "markdownText", column = "markdown_text"),
            @Result(property = "remarks", column = "remarks")})
    public List<ContentVO> getAllCategory();

    @Select("select taxonomy_id as id,count(*) as total from jpress_mapping group by taxonomy_id")
    @MapKey("id")
    public Map<String, CategoryCountVO> getCountByCategory();

}
